A Line chart demonstrating the axis options
This goes in the documents header:
<script src="RGraph.common.core.js"></script>
<script src="RGraph.line.js"></script>
Put this where you want the chart to show up:
<button onclick="obj = getObject(); obj.Set('xaxispos', obj.Get('xaxispos') == 'bottom' ? 'center' : 'bottom'); RGraph.Redraw();">Toggle the X axis position</button>
<button onclick="obj = getObject(); obj.Set('yaxispos', obj.Get('yaxispos') == 'left' ? 'right' : 'left'); RGraph.Redraw();">Toggle the Y axis position</button>
<button onclick="obj = getObject(); obj.Set('ylabels', obj.Get('ylabels') ? false : true); RGraph.Redraw();">Toggle the Y axis labels</button>
<button onclick="obj = getObject(); obj.Set('ylabels.specific', obj.Get('ylabels.specific') ? null : ['High','Medium','Low']); RGraph.Redraw();">Toggle specific Y axis labels</button>
<button onclick="obj = getObject(); obj.Set('ymin', obj.Get('ymin') ? 0 : 50); RGraph.Redraw();">Toggle ymin (50) setting</button>
<button onclick="obj = getObject(); obj.Set('noxaxis', obj.Get('noxaxis') ? false : true); RGraph.Redraw();">Toggle X axis </button>
<button onclick="obj = getObject(); obj.Set('labels', obj.Get('labels') ? null : ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']); RGraph.redraw();">Toggle X labels</button>
<br />
<canvas id="cvs" width="900" height="400">
[No canvas support]
</canvas>
This is the code that generates the chart:
<script>
function getObject ()
{
return RGraph.ObjectRegistry.getFirstObjectByType('line');
}
window.onload = function ()
{
var line = new RGraph.Line({
id: 'cvs',
data: [65,70,74,64,58,94,75,64,68,78,64,63],
options: {
ymax: 100,
xmax: 365,
labels: ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'],
xaxispos: 'center',
textSize: 16,
gutterBottom: 45,
gutterRight: 95,
gutterLeft: 85,
textAccessible: true
}
}).draw();
};
</script>